﻿package mortal.game.view.mainUI.smallMap.view.typeIconDataParser
{
    import Message.Public.*;
    import extend.language.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.mainUI.smallMap.view.data.*;

    public class SmallMap_MainCityBattleParser extends Object implements ISMallMapTyperIconDataParser
    {
        public var myEntityId:SEntityId;
        private static var _instance:SmallMap_MainCityBattleParser;

        public function SmallMap_MainCityBattleParser()
        {
            return;
        }// end function

        public function chooseIcon(param1:IEntity, param2:Array) : void
        {
            if (param1 is PetPlayer)
            {
                return;
            }
            var _loc_3:* = new SmallMapTypeIconData();
            _loc_3.x = param1.x2d;
            _loc_3.y = param1.y2d;
            _loc_3.name = "";
            _loc_3.tips = "";
            var _loc_4:* = param1.entityInfo.reserveJs.maincity_flag > 0;
            if (!_loc_4 && param1 is RolePlayer)
            {
                return;
            }
            var _loc_5:* = param1.entityInfo.entityInfo.entityId;
            var _loc_6:* = EntityUtil.isSameServer(this.myEntityId, _loc_5) && param1.entityInfo.entityInfo.guildId.id == Cache.instance.role.entityInfo.guildId.id;
            if (param1 is MonsterPlayer)
            {
                if ((param1 as MonsterPlayer).bossInfo.code == 40006204)
                {
                    _loc_4 = true;
                    _loc_6 = false;
                }
                else
                {
                    return;
                }
            }
            if (_loc_6)
            {
                if (!_loc_4)
                {
                    _loc_3.iconName = ImagesConst.MapPoint_greenPoint;
                    _loc_3.tips = param1.entityInfo.entityInfo.name;
                }
                else
                {
                    _loc_3.iconName = ImagesConst.MainCityFlag_Green;
                    _loc_3.tips = Language.getString(21284);
                    _loc_3.name = Language.getString(21284);
                    _loc_3.width = 32;
                    _loc_3.height = 32;
                }
            }
            else if (!_loc_4)
            {
                _loc_3.iconName = ImagesConst.MapPoint_MovePoint;
                _loc_3.tips = param1.entityInfo.entityInfo.name;
            }
            else
            {
                if (param1 is UserPlayer && param1.entityInfo.isDisappear)
                {
                    return;
                }
                _loc_3.iconName = ImagesConst.MainCityFlag_Red;
                _loc_3.tips = Language.getString(21285);
                _loc_3.name = Language.getString(21285);
                _loc_3.width = 32;
                _loc_3.height = 60;
            }
            param2.push(_loc_3);
            return;
        }// end function

        public static function get instance() : SmallMap_MainCityBattleParser
        {
            if (_instance == null)
            {
                _instance = new SmallMap_MainCityBattleParser;
                _instance.myEntityId = Cache.instance.role.roleEntityInfo.entityInfo.entityId;
            }
            return _instance;
        }// end function

    }
}
